//
//  Target_C.m
//  New_Runway
//
//  Created by 张记 on 2018/4/23.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "Target_C.h"
#import "NSObject+Target.h"
#import "TargetModel.h"
#import "NRWCarNotificationVC.h"
#import "CarBrowseHistoryVC.h"
#import "CollectionCarVC.h"
#import "SettingVC.h"
#import "PublicNoticeVC.h"

@implementation Target_C
- (void)Action_mine:(NSDictionary *)params
{
    NSString *vcType = params[@"params"][@"vc"];
    NSDictionary *jsonDic = [self dictionaryWithJsonString:vcType];
    TargetModel *model = [[TargetModel alloc] init];
    [model setValuesForKeysWithDictionary:jsonDic];
    if ([model.path isEqualToString:kMineCollectionPath]) {
        CollectionCarVC *collectVc = [[CollectionCarVC alloc] init];
        [[self getTopVC] cyl_pushViewController:collectVc animated:YES];
        
    }else if ([model.path isEqualToString:kMineHistoryPath]){
        CarBrowseHistoryVC *historyVc = [[CarBrowseHistoryVC alloc] init];
        [[self getTopVC] cyl_pushViewController:historyVc animated:YES];
    }else if ([model.path isEqualToString:kMinePublicPath]){
        PublicNoticeVC *publicVc = [[PublicNoticeVC alloc] init];
        [[self getTopVC] cyl_pushViewController:publicVc animated:YES];
    }else if ([model.path isEqualToString:kMineNoticePath]){
        NRWCarNotificationVC *notificaVc = [[NRWCarNotificationVC alloc] init];
        [[self getTopVC] cyl_pushViewController:notificaVc animated:YES];
    }else if ([model.path isEqualToString:kMineSettingPath]){
        SettingVC *setVc = [[SettingVC alloc] init];
        [[self getTopVC] cyl_pushViewController:setVc animated:YES];
    }
    
    
}
-(NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {
    if (jsonString == nil) {
        return nil;
    }
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
    if(error) {
        NSLog(@"json解析失败：%@",error);
        return nil;
    }
    return dic;
}

@end
